package org.dmcs.spring.webflow.service;

import java.util.logging.Logger;

import org.dmcs.spring.webflow.model.user.User;
import org.dmcs.spring.webflow.service.api.IAuthenticationService;
import org.dmcs.spring.webflow.service.api.IUserProviderService;

public class AuthenticationServiceMock implements IAuthenticationService {

	private static Logger LOGGER =  Logger.getLogger(AuthenticationServiceMock.class.getName());
	
	private IUserProviderService userProviderService;
	
	public boolean authenticate(User credentials) {
		
		User registeredUser = userProviderService.getUserCredentials();
		
		if(registeredUser.getUsername().equals(credentials.getUsername()) &&
				registeredUser.getPassword().equals(credentials.getPassword())) {
			
			LOGGER.info("UserCredentials with credentials: " + credentials + " authenticated positively.");
			
			return true;
		}
		
		LOGGER.info("UserCredentials with credentials: " + credentials + " not authenticated.");
		
		return false;
	}

	public void setUserProviderService(IUserProviderService userProviderService) {
		this.userProviderService = userProviderService;
	}
}